import { reactive, ref } from "vue";
import { getUserByPositionApi } from "@/api/common";
export default function InitHook() {
  const formState = reactive<Partial<{ userId: string }>>({
    userId: undefined
  });
  const loading = ref<boolean>(false);
  const formDataRef = ref<any>(null);
  const userOpts = ref<Array<Base.GeneraDataType>>([]);
  const getAllUserOpts = (position: number) => {
    return getUserByPositionApi({ position, status: 1 }).then((res: any) => {
      const { code, data } = res;
      if (code === 200) {
        userOpts.value = data || [];
      }
    });
  };
  return {
    formState,
    formDataRef,
    loading,
    userOpts,
    getAllUserOpts
  };
}
